package com.cskaoyan.bean;

import com.cskaoyan.vo.OrderDetailVo;
import com.cskaoyan.wx.bean.vo.DetailVo;
import lombok.Data;

import java.math.BigDecimal;
import java.sql.Date;

@Data
public class OrderGoods {
    private Integer id;

    private Integer orderId;

    private Integer goodsId;

    private String goodsName;

    private String goodsSn;

    private Integer productId;

    private Short number;

    private BigDecimal price;

    private String specifications;

    private String picUrl;

    private Integer comment;

    private Date addTime;

    private Date updateTime;

    private Boolean deleted;

    static public OrderGoods cartToOrderGoods(Cart cart, Integer orderId) {

        OrderGoods orderGoods = new OrderGoods();

        orderGoods.orderId = orderId;
        orderGoods.goodsId = cart.getGoodsId();
        orderGoods.goodsName = cart.getGoodsName();
        orderGoods.goodsSn = cart.getGoodsSn();
        orderGoods.productId = cart.getProductId();
        orderGoods.number = cart.getNumber();
        orderGoods.price = cart.getPrice();


        String[] specifications = cart.getSpecifications();

        StringBuilder s = new StringBuilder();
        for (String specification : specifications) {
            s.append(specification);
        }

        orderGoods.specifications = s.toString();
        orderGoods.picUrl = cart.getPicUrl();
        orderGoods.comment = 0;

        Date date = new Date(System.currentTimeMillis());

        orderGoods.addTime = date;
        orderGoods.updateTime = date;
        orderGoods.deleted = false;

        return orderGoods;

    }
}